package com.google.gsaguide.fragments;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;

import com.google.gsaguide.MainActivity;
import com.google.gsaguide.R;

public class ProgramFragment extends Fragment {

    // TODO: Need to improve this fragment content, optimize and comment this code.

    public ProgramFragment() {
    }

    public static ProgramFragment newInstance() {
        ProgramFragment fragment = new ProgramFragment();
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        View view = inflater.inflate(R.layout.fragment_program, container, false);

        WebView programView = (WebView) view.findViewById(R.id.program_view);
        programView.getSettings().setJavaScriptEnabled(true);
        programView.loadUrl("file:///android_asset/gsa_program/gsa_desc_" + getString(R.string.language) + ".html");
        return view;
    }

    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        ((MainActivity) activity).onSectionAttached(MainActivity.PROGRAM_FRAGMENT);
    }

    @Override
    public void onDetach() {
        super.onDetach();
    }

}
